package com.example.aspect.demo.controller;

import com.example.aspect.demo.WordProcess;
import com.lowagie.text.DocumentException;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

@Controller
public class AspectTestController {

    @GetMapping("/hello")
    public Map<String,Object> test(int account){
        Map<String,Object> retmMap=new HashMap<>();
         retmMap.put("1",account);
         retmMap.put("2","word");

          LinkedList l1=new LinkedList();
          l1.add(1);
          l1.get(0);
           return retmMap;
    }
    @GetMapping("/hello2")
    public  String test2(){


        return  "index";
    }

    @PostMapping("/excelTest")
    public void test(MultipartFile excel, HttpRequest request){
        //获取excel文件
   //     WorkbookFactory.create(is);   excel.getInputStream()


    }

    @GetMapping("/download")
    public void DownloadTest(HttpServletResponse  response) {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("content-disposition", "attachment; filename=" + "_info.doc");
        response.setContentType("text/json");
        response.setCharacterEncoding("UTF-8");

        WordProcess word = new WordProcess();


    }

//    @PostMapping
//    public void uploadFile(  HttpServletResponse response,  @RequestParam("file")  MultipartFile file,  @RequestParam("userId")){
//
//    }




}
